import urllib.request

# 当前要抓取的url网址
url = 'https://www.gushiwen.cn/'
headers = {
    'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36'
}
#  进行了一步伪装
req = urllib.request.Request(url, headers=headers)
# 对伪装对象发起请求
response = urllib.request.urlopen(req)
# print(response)
# 获取响应状态码
# print(response.getcode())
# 获取请求的url地址
# print(response.geturl())
# 获取响应数据
print(response.read().decode())
